package seconddemo;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.List;

public class ObjIn {
	public static void main(String[] args) {
		File file=new File("D:\\stu.dat");
		try {
			ObjectInputStream ois=new ObjectInputStream(new FileInputStream(file));
			try {
				List<Student> list=(List<Student>) ois.readObject();
				for (Student stu : list) {
					System.out.println(stu.getName()+" "+stu.getAge()+" "+stu.getAddr());
				}
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		}
	}
